<?php
/**
 * This file is part of Hyperf Mall.
 *
 * @link     https://gitee.com/scwlkj/hyperf_mall
 * @contact  hyperf_mall@163.com
 */

namespace App\Repository;

use App\Model\ArticleModel;
use Hyperf\Di\Annotation\Inject;

class ArticleRepository extends BaseRepository
{
    /**
     * @Inject
     * @var ArticleModel
     */
    protected $model;

    /**
     * Notes: 组装详情
     * Author: Bruce.z
     * DateTime: 2022/6/10 10:46
     * @param int $id
     * @return array
     */
    public function detail(int $id) :array
    {
        $detail = $this->getOne(['id'=>$id]);
        $detail['ids'] = ArticleCategoryRepository::getInstance()->getParentID($detail['category_id']);

        return $detail;
    }
}
